# Contributor: Celeste <cielesti@protonmail.com>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=ocaml-stk
pkgver=0.1.0
pkgrel=0
pkgdesc="SDL-based GUI toolkit"
url="https://framagit.org/zoggy/ocaml-stk"
arch="all !riscv64 !loongarch64" # ocaml
license="GPL-3.0-only"
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	ocaml-ctypes-dev
	ocaml-fmt-dev
	ocaml-higlo-dev
	ocaml-logs-dev
	ocaml-lwt-dev
	ocaml-ocf-dev
	ocaml-pcre-dev
	ocaml-ppx_blob-dev
	ocaml-sedlex-dev
	ocaml-tsdl-dev
	ocaml-tsdl-image-dev
	ocaml-tsdl-ttf-dev
	ocaml-uunf-dev
	ocaml-uutf-dev
	"
makedepends="
	$depends_dev
	dune
	ocaml
	"
subpackages="$pkgname-dev"
source="https://framagit.org/zoggy/ocaml-stk/-/archive/$pkgver/ocaml-stk-$pkgver.tar.bz2
	font.patch
	"
options="!check" # requires unpackaged landmarks-ppx

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --build-dir=.testenv --verbose
}

package() {
	dune install --destdir="$pkgdir" --docdir=/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; find usr/lib/ocaml \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\) | while read -r path
	do
		amove "$path"
	done
}

prepare_py_provides() {
	local datadir="${subpkgdir:-$pkgdir}"
	local pkgbasedir=${pkgbasedir:-"$startdir/pkg"}
	local controldir="$pkgbasedir"/.control.${subpkgname:-$pkgname}

	options_has "!tracedeps" && return 0

	ocaml4-abuild-find provides \
		"$datadir"/usr/lib/ocaml \
		"$controldir" \
		"$pkgver-r$pkgrel"
}

scan_python3_dependency() {
	local controldir="$2" datadir="$3"

	ocaml4-abuild-find requires \
		"$datadir"/usr/lib/ocaml \
		"$controldir"
}

sha512sums="
7978e3f10bc196ee6177ded9ae0313a5ba65e1a74e501fbecbe5ebc216ca6ee7117deaff5bc4c414083a4a55851a81e5dedaa8d0a880ad72689b3f56f3b064f5  ocaml-stk-0.1.0.tar.bz2
34fda34bdc19b8421429c3f01d6a4c4a0edf3dc4294b6d3c61b45483a2f88f497ab6b7401a25eb34001d334f1bfdc1cf8e50ce1205c97f8909d89b0f63db1671  font.patch
"
